﻿<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="FoodBookManagement.aspx.cs" Inherits="Admin_FoodBookManagement" Title="Food Book Management" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EatDrinkConnectionString %>"
        SelectCommand="SELECT * FROM [FoodStyle]"></asp:SqlDataSource>
    <telerik:RadCodeBlock ID="radCode" runat="server">

        <script type="text/javascript">
        function OpenPositionedWindow(oButton, url, windowName) {
            var oWnd = window.radopen(url, windowName);
        }
        function openRadWindow(FoodBookID)
        {
            var oWnd = radopen("FoodBookDetails_Admin.aspx?FoodBookID=" + FoodBookID, "RadWindow1");
            oWnd.setSize(700, 500);
            oWnd.center();
        }
        function ShowInsertForm()
        {
            var oWnd = radopen("FoodBookDetails_Admin.aspx" , "RadWindow1");
            oWnd.setSize(700, 500);
            oWnd.center();
        }
        function reloadPage()
        {
            var btn = document.getElementById("<%=btRefreshGrid.ClientID %>");
            btn.click();
        }
        </script>
    </telerik:RadCodeBlock>
    <table align="center" width="auto" border="0" bgcolor="White" style="height: 67px;
        background-image: url('Images/bg-snippet.png');">
        <tr>
            <td align="center" style="height: 25px">
                <asp:Label ID="Label1" runat="server" ForeColor="Red" Text="Bạn Chưa Nhập tên Món Ăn !!!"
                    Visible="False"></asp:Label>
                <asp:TextBox ID="txtSearch" runat="server" value="Nhập Tên Món Ăn Cần Tìm..." onblur="if(this.value=='') this.value='Nhập Tên Món Ăn Cần Tìm...';"
                    onfocus="if(this.value=='Nhập Tên Món Ăn Cần Tìm...') this.value='';" Style="width: 230px" />
                <asp:Button ID="btnSearch" runat="server" Text="Tìm Kiếm" BackColor="Aquamarine"
                    OnClick="btnSearch_Click" />
            </td>
        </tr>
    </table>
    <telerik:RadGrid ID="uxFoodBook" runat="server" AllowPaging="True" AllowSorting="True"
        AutoGenerateColumns="False" GridLines="None" OnNeedDataSource="uxFoodBook_NeedDataSource"
        Skin="Office2007" OnCancelCommand="uxFoodBook_CancelCommand" OnDeleteCommand="uxFoodBook_DeleteCommand"
        PageSize="7" >
        <HeaderContextMenu Skin="Office2007" EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </HeaderContextMenu>
        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
        <MasterTableView DataKeyNames="FoodBookID" CommandItemDisplay="TopAndBottom">
            <RowIndicatorColumn>
                <HeaderStyle Width="20px" Font-Bold="true"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn>
                <HeaderStyle Width="20px" Font-Bold="true"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <a href="#" onclick="openRadWindow('<%#DataBinder.Eval(Container.DataItem,"FoodBookID")%>'); return false;">
                            Edit</a>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn Visible="false" HeaderText="FoodBookID" UniqueName="FoodBookID"
                    DataField="FoodBookID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn Visible="false" DataField="Date" HeaderText="Date" UniqueName="Date">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ShortDescription" HeaderText="ShortDescription"
                    UniqueName="ShortDescription">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" Height="100px" Width="100px" ImageUrl='<%# Eval("Image", "~/Images/Foods/{0}") %>' />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="IsShowHomePage" HeaderText="Show Home Page" UniqueName="IsShowHomePage">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete"
                    ConfirmDialogType="RadWindow" ConfirmText="Are you sure you would like to delete this?"
                    ConfirmTitle="Delete">
                </telerik:GridButtonColumn>
            </Columns>
            <CommandItemTemplate>
                <a href="#" onclick="ShowInsertForm(); return false;" style="text-decoration: underline">
                    Thêm Món Ăn</a>
            </CommandItemTemplate>
        </MasterTableView>
        <FilterMenu EnableTheming="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
        </FilterMenu>
    </telerik:RadGrid>
    <asp:Button ID="btRefreshGrid" runat="server" OnClick="btRefreshGrid_Click" Style="display: none" />
    <telerik:RadWindowManager ID="InfoBox" runat="server" Width="900" Height="530" VisibleStatusbar="false"
        Behaviors="Close, Move, Resize , Maximize, Minimize" Skin="Office2007">
    </telerik:RadWindowManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"
        Width="75px">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'
            style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="uxFoodBook">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="uxFoodBook" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btRefreshGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="uxFoodBook" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>
